class Solution {
    public int minIncrementForUnique(int[] nums) {
        Arrays.sort(nums);
        int tmp = nums[0];
        int ans = 0;
        for(int i = 1;i<nums.length;i++){
            if(nums[i] <= tmp){
                ans += tmp - nums[i] + 1;
                nums[i] = tmp + 1;
            }
            tmp = nums[i];
        }return ans;
    }
}